/**
 * $RCSfile: ListenerProxy.java,v $
 * $Revision: 1.1 $
 * $Date: 2014/07/08 00:25:45 $
 *
 * Copyright (C) 2003 itjds, Inc. All rights reserved.
 *
 * This software is the proprietary information of itjds, Inc.
 * Use is subject to license terms.
 */
package com.ds.bpm.engine.proxy;

import java.io.Serializable;

import com.ds.bpm.client.Listener;
import com.ds.bpm.engine.inter.EIListener;
import com.ds.bpm.enums.event.ActivityEventEnums;
import com.ds.bpm.enums.event.ListenerEnums;
import com.ds.bpm.enums.event.ListenerTypeEnums;
import com.ds.bpm.enums.event.ProcessEventEnums;
import com.ds.bpm.enums.event.RightEventEnums;
import com.ds.enums.EventEnums;

/**
 * <p>
 * Title: JDS系统管理系统
 * </p>
 * <p>
 * Description: 客户端监听器接口的代理实现
 * </p>
 * <p>
 * Copyright: Copyright (c) 2006
 * </p>
 * <p>
 * Company: www.justdos.net
 * </p>
 * 
 * @author wenzhang li
 * @version 1.0
 */
public class ListenerProxy implements Listener, Serializable {

    private EIListener eiListener;
    private String systemCode;

    public ListenerProxy(EIListener eiListener, String systemCode) {
	this.systemCode = systemCode;
	this.eiListener = eiListener;
    }

    /*
     * @see com.ds.bpm.client.Listener#getListenerId()
     */
    public String getListenerId() {
	return eiListener.getListenerId();
    }

    /*
     * @see com.ds.bpm.client.Listener#getListenerName()
     */
    public String getListenerName() {
	return eiListener.getListenerName();
    }

    /*
     * @see com.ds.bpm.client.Listener#getListenerEvent()
     */
    public ListenerEnums getListenerEvent() {
	return ListenerEnums.fromType(eiListener.getListenerEvent());
    }

    /*
     * @see com.ds.bpm.client.Listener#getRealizeClass()
     */
    public String getRealizeClass() {
	return eiListener.getRealizeClass();
    }

    public EventEnums getExpressionEventType() {

	ListenerEnums listenerType = ListenerEnums.fromType(eiListener.getExpressionListenerType());

	switch (listenerType) {
	case ACTIVITY_LISTENER_EVENT:
	    return ActivityEventEnums.fromMethod(eiListener.getExpressionEventType());
	case PROCESS_LISTENER_EVENT:
	    return ProcessEventEnums.fromMethod(eiListener.getExpressionEventType());
	case RIGHT_LISTENER_EVENT:
	    return RightEventEnums.fromMethod(eiListener.getExpressionEventType());
	default:
	    break;
	}
	return null;
    }

    public ListenerTypeEnums getExpressionListenerType() {
	return ListenerTypeEnums.fromType(eiListener.getExpressionListenerType());
    }

    public String getExpressionStr() {
	return eiListener.getExpressionStr();
    }

}
